<html>
<head><meta charset="utf-8"><title>non-generic rowan · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html">non-generic rowan</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="162606308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/162606308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#162606308">(Apr 05 2019 at 09:18)</a>:</h4>
<p>Would love to get some feedback on <a href="https://github.com/rust-analyzer/rowan/pull/13" target="_blank" title="https://github.com/rust-analyzer/rowan/pull/13">https://github.com/rust-analyzer/rowan/pull/13</a></p>
<p>This PR makes the sytnax tree library we use non-generic, which might be a good trade off considering that the tree itself never uses generic parameters itself.</p>



<a name="164385032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385032">(Apr 28 2019 at 12:33)</a>:</h4>
<p>I've been using <code>rowan</code> as the underlying framework for my parser and I'm a big fan of this. Is there any appetite in pulling out <code>rust-analyzer/ra_parser</code>s event-driven parsing framework to rowan (or a separate crate)? I think it has a lot of potential for generic IDE tooling, e.g., could be used to build a Rust solution to IntelliJ's GrammarKit.</p>



<a name="164385165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385165">(Apr 28 2019 at 12:37)</a>:</h4>
<p><span class="user-mention" data-user-id="210215">@Gary Tierney</span> I've actually experimented with rust Grammar Kit thing before rowan: <a href="https://github.com/matklad/fall" target="_blank" title="https://github.com/matklad/fall">https://github.com/matklad/fall</a></p>



<a name="164385168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385168">(Apr 28 2019 at 12:37)</a>:</h4>
<p>was able to parse full rust with ti: <a href="https://github.com/matklad/fall/blob/master/lang/rust/syntax/src/rust.fall" target="_blank" title="https://github.com/matklad/fall/blob/master/lang/rust/syntax/src/rust.fall">https://github.com/matklad/fall/blob/master/lang/rust/syntax/src/rust.fall</a></p>



<a name="164385218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385218">(Apr 28 2019 at 12:38)</a>:</h4>
<p>As for pulling away the parsing framework, that's a good question!</p>



<a name="164385223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385223">(Apr 28 2019 at 12:38)</a>:</h4>
<p>I am increasingly becoming convinced that parser and syntax tree should be completely orthogonal</p>



<a name="164385244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385244">(Apr 28 2019 at 12:39)</a>:</h4>
<p>So, there probably shouldn't be "rowan-specific" parser framework</p>



<a name="164385292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385292">(Apr 28 2019 at 12:40)</a>:</h4>
<p>I am however not sure how exactly the API between the parser and the tree builder should look like</p>



<a name="164385295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385295">(Apr 28 2019 at 12:40)</a>:</h4>
<p>the main question here is "to type or not to type" :-)</p>



<a name="164385309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385309">(Apr 28 2019 at 12:41)</a>:</h4>
<p>If we go with untyped version, that something like IntelliJ's marks (don't remmeber how they are called) should work</p>



<a name="164385345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385345">(Apr 28 2019 at 12:42)</a>:</h4>
<p>However, the API should allow to construct a typed tree as well, and I don't know how to do that nicely</p>



<a name="164385372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385372">(Apr 28 2019 at 12:42)</a>:</h4>
<p>that actually is an extremely interesting question! One thing we'd want to do in the future is to share the parser between rust-analyzer and rustc, and this setup will require us to have this kind of abstract parser</p>



<a name="164385437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385437">(Apr 28 2019 at 12:44)</a>:</h4>
<p>e.g., a tree of some syntax tree type <code>T</code>, as opposed to a tree of <code>rowan::SyntaxKind</code>?</p>



<a name="164385539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385539">(Apr 28 2019 at 12:47)</a>:</h4>
<p>Not just a single type T, but like a tree of <code>StructDef</code> which has <code>FieldDef</code>s inside</p>



<a name="164385545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385545">(Apr 28 2019 at 12:47)</a>:</h4>
<p>Like, when you write traditional parser, the types in AST guide you</p>



<a name="164385751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/non-generic%20rowan/near/164385751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gary Tierney <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/non-generic.20rowan.html#164385751">(Apr 28 2019 at 12:52)</a>:</h4>
<p>hmm, I will think about that a bit and how it might fit into the existing <code>TreeSink</code> work. I can appreciate the independence of syntax tree and parser. I think that's what enables making rapid changes to this sort of stuff.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>